package com.powergisol.gis.timer;

import com.powergisol.gis.service.FallBackService;
import com.powergisol.gis.service.IFileService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.*;


//@Component
public class SynchronizeFilesTimer {

    private static Logger logger = LoggerFactory.getLogger(SynchronizeFilesTimer.class);

    @Autowired
    private FallBackService fallBackService;
    @Autowired
    private IFileService fileService;

    //@Scheduled(initialDelay = 6000, fixedRate = 3600)
   // @Scheduled(fixedRate = 1000*60*10)
    public void SynFile(){
        List<Map<String,Object>> list = fallBackService.getSynService();
        logger.info("同步数据={}条",list.size());
        for (Map<String,Object> map:list){
            fileService.writeToDisk(map.get("uuid").toString(),map.get("file_url").toString());
        }
    }

}
